package top.anonyeast.pojo;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Map;


/*
    @ConfigurationProperties作用：
    将配置文件中配置的每一个属性的值，映射到这个组件中；
    告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定
    参数 prefix = “person” : 将配置文件中的person下面的所有属性一一对应
*/
@ConfigurationProperties(prefix = "person")
@Data
@Validated //数据校验
@Component //注册bean
public class Person {
    @NotNull(message="名字不能为空")
    private String name;
    @Max(value = 100,message = "年龄超过100是不现实的")
    @Min(value = 0,message = "年龄小于0是不科学的")
    private Integer age;
    private Boolean isHappy;
    private Date birthday;
    @Email(message = "邮箱格式不正确")
    private String email;
    private Map<String,Object> maps;
    private List<Object> list;
    private Dog dog;
}
